<template>
  <div>
    <div class="back_add"
      :class="phone=='true'?'1':'2'">
      <div class="threeImg">
        <div class="Containt">
          <div
            class="iconleft"
            v-if="type == 1"
            @click="zuohua">
            <i
              class="el-icon-arrow-left"></i>
          </div>
          <!-- 'left':calleft + 'px' 是 ul 向左偏移的量 -->
          <ul
            style="transition: all 0.5s ease 0s;"
            :style="{'left':calleft + 'px'}"
            v-on:mouseover="stopmove()"
            v-on:mouseout="move()">
            <li
              v-for="(item,index) in superurl"
              @click="openUrl(item)"
              :key="index">
              <img
                :src="item.imgUrl" />
            </li>
          </ul>
          <div
            v-if="type == 1"
            class="iconright"
            @click="youhua">
            <i
              class="el-icon-arrow-right"></i>
          </div>

        </div>
      </div>

    </div>
  </div>
</template>
<script>
export default {
  props: {
    superurl: {
      type: Array,
      default: () => []
    },
    times: {
      type: Number,
      default: () => {}
    },
    type: {
      type: Number,
      default: () => {}
    },
    phone: {
      type: String,
      default: () => {}
    }
  },
  data() {
    return {
      //price不是很重要，重要的是url
      calleft: 0 //calleft是整个数据的偏移量
    }
  },
  mounted() {
    setTimeout(() => {
      if (this.type == 2) {
        this.move()
      }
    }, 1000)
  },
  methods: {
    openUrl(e) {
      window.open(e.url)
    },
    //移动
    move() {
      this.timer = setInterval(this.starmove, this.times)
    },
    //开始移动
    starmove() {
      // 340是根据自己图片的大小自己设置的，点击一下整体向左平移多少
      this.calleft -= 340
      if (this.calleft < -1200) {
        this.calleft = 0
      }
    },
    //鼠标悬停时停止移动
    stopmove() {
      clearInterval(this.timer)
    },
    //点击按钮左移
    zuohua() {
      this.calleft -= 340
      if (this.calleft < -1200) {
        this.calleft = 0
      }
    },
    //点击按钮右移
    youhua() {
      this.calleft += 340
      if (this.calleft > 0) {
        this.calleft = -1020
      }
    }
  }
}
</script>
<style scoped>
/*超链接图片*/

#divAdd {
  width: 100%;
  min-width: 1200px;
  width: 1000px;
  margin: 0px auto;
}

.divAdd-con {
  margin: 0px auto;
  width: 1000px;
  overflow: auto;
  padding: 30px 0px;
}

.divAdd-con img {
  float: left;
}

.indexrt {
  margin: 0px 40px;
}

.divAddleft img {
  float: left;
  margin-bottom: 7px;
}

.divAddleft {
  float: left;
  display: inline;
  width: 370px;
}

.divAddrt {
  float: right;
  display: inline;
  margin-top: 7px;
}

.back_add {
  /* background-color: #ededed; */
}

.divAdd-con img {
  border: none;
}

a:focus,
a:hover {
  color: #23527c;
}

.threeImg {
  height: 150px;
  min-width: 100%;
}

.threeImg .Containt ul {
  margin: 0 auto;
  width: 2400px;
  position: absolute;
  left: 0px;
  cursor: pointer;
  height: 100%;
}

.threeImg .Containt ul li {
  width: 300px;
  margin-right: 10px;
  margin-left: 30px;
  margin-top: 0px;
  float: left;
}

.threeImg .Containt ul li img {
  height: 150px;
  width: 100%;
}

.Containt {
  position: relative;
  width: 375px;
  height: 150px;

  overflow: hidden;
  margin: 0 auto;
}

.iconleft {
  position: absolute;
  width: 20px;
  height: 80px;
  left: 0px;
  top: 10px;
  z-index: 99999;
  padding-top: 48px;
  vertical-align: middle;
}

.iconright {
  /* position: relative; */
  right: 10px;
  top: 70px;
  position: absolute;
  width: 20px;
  height: 80px;
  top: 10px;
  z-index: 99999;
  padding-top: 48px;
  vertical-align: middle;
}
</style>